package fr.emn.integration.synthese.controle;

import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JButton;
import javax.swing.JMenuItem;

import fr.emn.integration.synthese.abstraction.BDCours;
import fr.emn.integration.synthese.abstraction.Cours;
import fr.emn.integration.synthese.presentation.EleveDialog;
import fr.emn.integration.synthese.presentation.GroupeDialog;

public class ControlJButtonPlusEleve implements ActionListener, Observer {

	private Cours modele;
	private Frame parent;
	private BDCours BD;
	private JMenuItem item;

	public ControlJButtonPlusEleve(Frame parent, Cours modele, BDCours BD, JMenuItem item) {
		this.modele = modele;
		this.parent = parent;
		this.BD=BD;
		this.item=item;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		EleveDialog EleveDialog = new EleveDialog(parent, modele,BD, true);
		EleveDialog.setVisible(true);
	}

	@Override
	public void update(Observable arg0, Object arg1) {
		if (modele.getModuleNames().isEmpty()){
			this.item.setEnabled(false);
		}
		else{
			this.item.setEnabled(true);
		}
		
	}
}
